package com.tanquandan.askbackend.controller;

import com.tanquandan.askbackend.dto.R;
import com.tanquandan.askbackend.entity.User;
import com.tanquandan.askbackend.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("/login")
    public R<User> login(HttpServletRequest request, @RequestBody User user){
       return userService.login(request,user);
    }


    @GetMapping("/listAll")
    public R<List<User>> list(){
       return R.success(userService.list());
    }

}
